//========================================================================
// *作者：海盗猫  主页：ilplay.com
// *脚本：IUIDisplayLife
// *描述：UI生命周期和事件监听的统一实现
// *?2021 MYJL . All rights reserved.
//* ======================================================================
using System.Collections.Generic;
using UnityEngine;
namespace HDMCode.UIFrame
{
    [DisallowMultipleComponent]
    public abstract class IUIDisplayLife : MonoBehaviour, IUIDisplayInfaceLife
    {
        /// <summary>
        /// UI首次加载时执行
        /// </summary>
        /// <param name="entity">当前UI对象</param>
        public virtual void OnLoadUI(UIEntity entity) { }
        
        /// <summary>
        /// UI首次传参加载时执行
        /// </summary>
        /// <param name="value"></param>
        /// <param name="entity"></param>
        /// <typeparam name="T"></typeparam>
        public virtual void OnLoadUI<T>(T value,UIEntity entity) { }

        /// <summary>
        /// UI显示时执行
        /// </summary>
        /// <param name="entity">当前UI对象</param>
        public abstract void OnDisplay(UIEntity entity);

        /// <summary>
        /// UI销毁时执行
        /// </summary>
        /// <param name="entity">当前UI</param>
        /// <param name="release">销毁的方式</param>
        public virtual void OnDestroyUI(UIEntity entity,UIEntityRelease release)=> release.Remove();

        /// <summary>
        /// UI传参显示时执行
        /// </summary>
        /// <param name="value">传递的参数</param>
        /// <param name="entity">当前UI</param>
        /// <typeparam name="T">传递的类型</typeparam>
        public virtual void OnDisplay<T>(T value,UIEntity entity) { }

        /// <summary>
        /// UI克隆时执行
        /// </summary>
        /// <param name="value">需要克隆的参数</param>
        /// <param name="clone">克隆UI对象</param>
        /// <param name="components">当前UI拥有的组件</param>
        /// <typeparam name="T">当前参数类型</typeparam>
        public virtual void OnClone<T>(T value,GameObject clone,List<UIComponentElement> components) { }
        
        /// <summary>
        /// 当前UI下的任意按钮被触发时执行
        /// </summary>
        /// <param name="com">触发的组件</param>
        public virtual void OnButtonEvent(Component com) { }
        
        /// <summary>
        /// 当前UI下的任意选项组件被触发时执行
        /// </summary>
        /// <param name="com">触发的组件</param>
        /// <param name="value">触发时的参数</param>
        public virtual void OnToggleEvent(Component com,bool value) { }
        
        /// <summary>
        /// 当前UI下的任意滑动组件被触发时执行
        /// </summary>
        /// <param name="com">触发的组件</param>
        /// <param name="value">触发时的参数</param>
        public virtual void OnSliderEvent(Component com,float value) { }
        
        /// <summary>
        /// 当前UI下的任意文本组件被触发时执行
        /// </summary>
        /// <param name="com">触发的组件</param>
        /// <param name="value">触发时的参数</param>
        public virtual void OnInputFieldEvent(Component com,string value) { }
        
        /// <summary>
        /// 当前UI下的滚动栏组件被触发时执行
        /// </summary>
        /// <param name="com">触发的组件</param>
        /// <param name="value">触发时的参数</param>
        public virtual void OnScrollbarEvent(Component com,float value) { }
        
        /// <summary>
        /// 当前UI下的滚动框组件被触发时执行
        /// </summary>
        /// <param name="com">触发的组件</param>
        /// <param name="value">触发时的参数</param>
        public virtual void OnScrollRectEvent(Component com, Vector2 value) { }
    }
}
